package zj;

import javax.swing.plaf.synth.SynthTabbedPaneUI;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
import java.util.Stack;

/**
 * @author code_yc
 * @version 1.0
 * @date 2020/7/31 13:59
 */
public class Solution3 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int l = sc.nextInt();
        Stack<Integer> stack = new Stack<>();
        int[] arr = new int[l];
        for (int i = 0; i < l; i++) {
            arr[i] = sc.nextInt();
            stack.push(arr[i]);
        }
        while (!stack.isEmpty()) {
            int c = stack.pop();
            quickSort(arr, c);
            print(arr);
        }
    }

    private static void quickSort(int[] arr, int c) {
        int less = -1;
        int more = arr.length;
        int index = 0;
        while (index < more) {
            if (arr[index] < c) {
                swap(arr, ++less, index++);
            } else if (arr[index] > c) {
                swap(arr, --more, index);
            } else {
                index++;
            }
        }
    }

    private static void print(int[] arr) {
        StringBuilder res = new StringBuilder();
        for (int n : arr) {
            res.append(n + " ");
        }
        res.deleteCharAt(res.length() - 1);
        System.out.println(res.toString());
    }

    private static void swap(int[] arr, int i, int j) {
        int temp = arr[i];
        arr[i] = arr[j];
        arr[j] = temp;
    }
}
